package com.spring.security.social.qq.connet;


import com.spring.security.social.qq.api.QQ;
import com.spring.security.social.qq.api.QQImpl;
import org.springframework.social.oauth2.AbstractOAuth2ServiceProvider;

public class QQServiceProvider extends AbstractOAuth2ServiceProvider<QQ> {
    private String appId;

    //将用户导向到认证服务器的url  获取Authorization Code
    private static final String URL_AUTHORIZE="https://graph.qq.com/oauth2.0/authorize";

    //认证服务器返回授权码的url  通过Authorization Code获取Access Token
    private static final String URL_ACCESSTOKEN="https://graph.qq.com/oauth2.0/token";

    public QQServiceProvider(String appId,String appSecret) {
        //String clientId, String clientSecret, String authorizeUrl, String accessTokenUrl
        super(new QQOAuth2Template(appId,appSecret,URL_AUTHORIZE,URL_ACCESSTOKEN));
        this.appId = appId;
    }

    @Override
    public QQ getApi(String accessToken) {

        return new QQImpl(accessToken, appId);
    }
}
